//
//  BK_SP_ ReminderView.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/4/1.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_SP_ReminderView.h"
#import <Masonry.h>
#import "BK_OD_Color.h"


#define Width_PicLogo   20
#define Width_Btn       200
#define Height_Selected 111/2.0

@interface BK_SP_ReminderView ()

@property (nonatomic,strong)UIButton * btn_cancle;
@property (nonatomic,strong) UIView * view_line;


@end

@implementation BK_SP_ReminderView
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        [self createUI];
        
    }
    return self;
}

-(void)createUI{
    _view_detail =[[UIView alloc]init];
    _view_detail.backgroundColor=[UIColor whiteColor];
    [self addSubview:_view_detail];
    [_view_detail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.width.mas_equalTo(ScreenWidth);
        make.height.mas_equalTo(745/2.0);
    }];
    
    /*
     * 取消按钮
     */
    _btn_cancle=[[UIButton alloc]init];
    _btn_cancle.backgroundColor=[UIColor clearColor];
    [_btn_cancle addTarget:self action:@selector(Btn_Cancle:) forControlEvents:UIControlEventTouchUpInside];
    [_btn_cancle setImage:[UIImage imageNamed:@"BK_PayStore_close"] forState:UIControlStateNormal];
    [_view_detail addSubview:_btn_cancle];
    [_btn_cancle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_view_detail.mas_top).offset(ApplicationBackGauge);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.width.mas_equalTo(25);
        make.height.mas_equalTo(25);
    }];
    
    
    /*
     * 需付款
     */
    _lab_NeedMoney=[[UILabel alloc]init];
    _lab_NeedMoney.text=@"加载中...";
    _lab_NeedMoney.textColor=kOrderBlack1;
    _lab_NeedMoney.font=[UIFont systemFontOfSize:18];
    _lab_NeedMoney.textAlignment=NSTextAlignmentCenter;
    [_view_detail  addSubview:_lab_NeedMoney];
    [_lab_NeedMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_view_detail.mas_top).offset(16.0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
    }];
    
    
    /*
     * 账户余额不足，请重新选择扣款账户
     */
    _lab_Tip=[[UILabel alloc]init];
    _lab_Tip.text=@"余额不足，请重新选择支付方式扫码支付";
    _lab_Tip.textColor=kOrderPriceRed2;
    _lab_Tip.font=[UIFont systemFontOfSize:13];
    _lab_Tip.textAlignment=NSTextAlignmentCenter;
    [_view_detail  addSubview:_lab_Tip];
    [_lab_Tip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lab_NeedMoney.mas_bottom).offset(5.5);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
    }];
    
    
    /**
     *  下划线
     */
    _view_line = [UILabel new];
    _view_line.backgroundColor = kOrderLineGrey2;
    [_view_detail addSubview:_view_line];
    [_view_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(_view_detail.mas_top).offset(169/2.0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.height.mas_equalTo(@(0.5));
    }];
    
    
    
    /*
     * 余额账户
     */
    _ImgV_Balance=[[UIImageView alloc]init];
    _ImgV_Balance.backgroundColor = [UIColor whiteColor];
    _ImgV_Balance.contentMode = UIViewContentModeScaleToFill;
    _ImgV_Balance.image=[UIImage imageNamed:@"BK_PayStore_YuE"];
    [_view_detail addSubview:_ImgV_Balance];
    [_ImgV_Balance mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_view_line.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.width.mas_equalTo(@(Width_PicLogo));
        make.height.mas_equalTo(@(Width_PicLogo));
    }];
    
    
    _lab_Balance = [UILabel new];
    _lab_Balance.textColor = kOrderBlack1;
    _lab_Balance.font = [UIFont systemFontOfSize:14];
    _lab_Balance.numberOfLines=1;
    _lab_Balance.text = @"余额账户";
    _lab_Balance.textAlignment=NSTextAlignmentLeft;
    _lab_Balance.backgroundColor = [UIColor clearColor];
    [_view_detail addSubview:_lab_Balance];
    [_lab_Balance mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_Balance.mas_centerY);
        make.left.mas_equalTo(_ImgV_Balance.mas_right).offset(10);
//        make.right.mas_equalTo(self.mas_right).offset(-100);
        make.width.mas_equalTo(61.5+5);
    }];
    
    
    
    /*
     * 账户余额
     */
    _lab_BalanceNum = [UILabel new];
    _lab_BalanceNum.textColor = kOrderMediumGrey1;
    _lab_BalanceNum.font = [UIFont systemFontOfSize:15];
    _lab_BalanceNum.numberOfLines=1;
    _lab_BalanceNum.text = @"";
    _lab_BalanceNum.textAlignment=NSTextAlignmentLeft;
    _lab_BalanceNum.backgroundColor = [UIColor clearColor];
    [self addSubview:_lab_BalanceNum];
    [_lab_BalanceNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_lab_Balance.mas_centerY);
        make.left.mas_equalTo(_lab_Balance.mas_right).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        
    }];

    
    
    _btn_Balance=[[UIButton alloc]init];
    _btn_Balance.backgroundColor=[UIColor clearColor];
    _btn_Balance.tag=1010;
//    [_btn_Balance addTarget:self action:@selector(Btn_Selected:) forControlEvents:UIControlEventTouchUpInside];
//    [_btn_Balance setImage:[UIImage imageNamed:@"BK_my_addressUnSelected"] forState:UIControlStateNormal];
//    [_btn_Balance setImage:[UIImage imageNamed:@"BK_my_addressDefaultSelected"] forState:UIControlStateSelected];
//    [_btn_Balance setSelected:NO];
    //button图片的偏移量，距上左下右分别(10, 10, 10, 60)像素点
    [_btn_Balance setImageEdgeInsets:UIEdgeInsetsMake(0, Width_Btn, 0, 0)];
    [_view_detail addSubview:_btn_Balance];
    [_btn_Balance mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_Balance.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.width.mas_equalTo(Width_PicLogo+Width_Btn);
        make.height.mas_equalTo(Width_PicLogo);
    }];
    
    
    
    _view_line2 = [UILabel new];
    _view_line2.backgroundColor = kOrderLineGrey2;
    [_view_detail addSubview:_view_line2];
    [_view_line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(_ImgV_Balance.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.height.mas_equalTo(@(0.5));
    }];
    
    
    
    
    
    
    
    /*
     * 支付宝账户
     */
    _ImgV_Alipay=[[UIImageView alloc]init];
    _ImgV_Alipay.backgroundColor = [UIColor whiteColor];
    _ImgV_Alipay.contentMode = UIViewContentModeScaleToFill;
    _ImgV_Alipay.image=[UIImage imageNamed:@"BK_PayStore_zhufubao"];
    [_view_detail addSubview:_ImgV_Alipay];
    [_ImgV_Alipay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_view_line2.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.width.mas_equalTo(@(Width_PicLogo));
        make.height.mas_equalTo(@(Width_PicLogo));
    }];
    
    
    _lab_Alipay = [UILabel new];
    _lab_Alipay.textColor = kOrderBlack1;
    _lab_Alipay.font = [UIFont systemFontOfSize:14];
    _lab_Alipay.numberOfLines=1;
    _lab_Alipay.text = @"支付宝账户";
    _lab_Alipay.textAlignment=NSTextAlignmentLeft;
    _lab_Alipay.backgroundColor = [UIColor clearColor];
    [_view_detail addSubview:_lab_Alipay];
    [_lab_Alipay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_Alipay.mas_centerY);
        make.left.mas_equalTo(_ImgV_Alipay.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
    }];
    
    
    _btn_Alipay=[[UIButton alloc]init];
    _btn_Alipay.backgroundColor=[UIColor clearColor];
    _btn_Alipay.tag=1020;
    [_btn_Alipay addTarget:self action:@selector(Btn_Selected:) forControlEvents:UIControlEventTouchUpInside];
    [_btn_Alipay setImage:[UIImage imageNamed:@"BK_my_addressUnSelected"] forState:UIControlStateNormal];
    [_btn_Alipay setImage:[UIImage imageNamed:@"BK_my_addressDefaultSelected"] forState:UIControlStateSelected];
    [_btn_Alipay setSelected:NO];
    //button图片的偏移量，距上左下右分别(10, 10, 10, 60)像素点
    [_btn_Alipay setImageEdgeInsets:UIEdgeInsetsMake(0, Width_Btn, 0, 0)];
    [_view_detail addSubview:_btn_Alipay];
    [_btn_Alipay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_Alipay.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.width.mas_equalTo(Width_PicLogo+Width_Btn);
        make.height.mas_equalTo(Width_PicLogo);
    }];
    
    
    
    _view_line3 = [UILabel new];
    _view_line3.backgroundColor = kOrderLineGrey2;
    [_view_detail addSubview:_view_line3];
    [_view_line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(_ImgV_Alipay.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.height.mas_equalTo(@(0.5));
    }];
    
    
    /*
     * 微信账户
     */
    _ImgV_WeChat=[[UIImageView alloc]init];
    _ImgV_WeChat.backgroundColor = [UIColor whiteColor];
    _ImgV_WeChat.contentMode = UIViewContentModeScaleToFill;
    _ImgV_WeChat.image=[UIImage imageNamed:@"BK_PayStore_wechat"];
    [_view_detail addSubview:_ImgV_WeChat];
    [_ImgV_WeChat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_view_line3.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.width.mas_equalTo(@(Width_PicLogo));
        make.height.mas_equalTo(@(Width_PicLogo));
    }];
    
    
    _lab_WeChat = [UILabel new];
    _lab_WeChat.textColor = kOrderBlack1;
    _lab_WeChat.font = [UIFont systemFontOfSize:14];
    _lab_WeChat.numberOfLines=1;
    _lab_WeChat.text = @"微信账户";
    _lab_WeChat.textAlignment=NSTextAlignmentLeft;
    _lab_WeChat.backgroundColor = [UIColor clearColor];
    [_view_detail addSubview:_lab_WeChat];
    [_lab_WeChat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_WeChat.mas_centerY);
        make.left.mas_equalTo(_ImgV_WeChat.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-100);
    }];
    
    
    _btn_WeChat=[[UIButton alloc]init];
    _btn_WeChat.backgroundColor=[UIColor clearColor];
    _btn_WeChat.tag=1030;
    [_btn_WeChat addTarget:self action:@selector(Btn_Selected:) forControlEvents:UIControlEventTouchUpInside];
    _btn_WeChat.userInteractionEnabled=YES;
    [_btn_WeChat setImage:[UIImage imageNamed:@"BK_my_addressUnSelected"] forState:UIControlStateNormal];
    [_btn_WeChat setImage:[UIImage imageNamed:@"BK_my_addressDefaultSelected"] forState:UIControlStateSelected];
    [_btn_WeChat setSelected:NO];
    //button图片的偏移量，距上左下右分别(10, 10, 10, 60)像素点
    [_btn_WeChat setImageEdgeInsets:UIEdgeInsetsMake(0, Width_Btn, 0, 0)];
    [_view_detail addSubview:_btn_WeChat];
    
    [_btn_WeChat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_ImgV_WeChat.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.width.mas_equalTo(Width_PicLogo+Width_Btn);
        make.height.mas_equalTo(Width_PicLogo);
    }];
    
    
    _view_line4 = [UILabel new];
    _view_line4.backgroundColor = kOrderLineGrey2;
    [_view_detail addSubview:_view_line4];
    [_view_line4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(_ImgV_WeChat.mas_bottom).offset((Height_Selected-Width_PicLogo)/2.0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.height.mas_equalTo(@(0.5));
    }];
    
    
    
    
}

-(void)Btn_Cancle:(UIButton *)btn{
    if ([self.delegate respondsToSelector:@selector(BK_SP_Reminder_clicked_Cancle)]) {
        [self.delegate BK_SP_Reminder_clicked_Cancle];
    }
}


-(void)Btn_Selected:(UIButton *)btn{
    [self Btn_SelectedWithTag:btn.tag];

    if ([self.delegate respondsToSelector:@selector(BK_SP_Reminder_clicked_Type:)]) {
        [self.delegate BK_SP_Reminder_clicked_Type:btn.tag-1000];
    }

}

-(void)Btn_SelectedWithTag:(NSInteger)tag{
    if (tag==1010) {
        [_btn_Balance setSelected:YES];
        [_btn_Alipay setSelected:NO];
        [_btn_WeChat setSelected:NO];
    }else if (tag==1020){
        [_btn_Balance setSelected:NO];
        [_btn_Alipay setSelected:YES];
        [_btn_WeChat setSelected:NO];
    }else if (tag==1030){
        [_btn_Balance setSelected:NO];
        [_btn_Alipay setSelected:NO];
        [_btn_WeChat setSelected:YES];
    }
}

-(void)relayOut_NeedMoney:(NSString *)money{
    NSString *str_money=[NSString stringWithFormat:@"%.2f",[[NSString stringWithFormat:@"%@",money] floatValue]];
    _lab_NeedMoney.text=[NSString stringWithFormat:@"需付款 ¥%@",str_money];
}
-(void)relayOut_CountMoney:(NSString *)money{
    
    _lab_Balance.textColor = kOrderMediumGrey1;
    _lab_Balance.alpha=0.7;
    _lab_BalanceNum.textColor = kOrderMediumGrey1;
    _lab_BalanceNum.alpha=0.7;
    
    
    if (money) {
        
        money=[NSString stringWithFormat:@"%@",money];
        
        money=[NSString stringWithFormat:@"¥%.2f",[money floatValue]];
        
        _lab_BalanceNum.text = money;
    }
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end































